"""
    create by IAmFiveHigh on 2024/8/10
"""
from typing import List

from priority_queue import PriorityQueue


class Solution:
    def smallestK(self, arr: List[int], k: int) -> List[int]:
        if len(arr) == 0 or k == 0 or len(arr) < k:
            return []

        queue = PriorityQueue()
        for i in range(k):
            queue.enqueue(arr[i])

        for j in range(k, len(arr)):
            if arr[j] < queue.get_front():
                queue.dequeue()
                queue.enqueue(arr[j])
        ret = []
        for k in range(k):
            ret.append(queue.dequeue())
        return ret


if __name__ == '__main__':
    l1 = [1, 3, 5, 7, 2, 4, 6, 8]
    k = 0
    print(Solution().smallestK(l1, k))
